package com.seeyon.apps.ext.ObxMsgPush.service;

import java.time.LocalDateTime;
import com.seeyon.apps.ext.ObxMsgPush.utils.MyUtils;
import com.seeyon.ctp.util.annotation.Inject;

public class AppService {
	@Inject
    private AppTokenStorage appTokenStorage;

    public String getToken() {
        String token = appTokenStorage.getToken();
        if (token == null) {
            // 当token过期或不存在时重新获取token
            token = MyUtils.getAccessToken("app");
            // 假设token的过期时间为5分钟
            LocalDateTime expirationTime = LocalDateTime.now().plusMinutes(3);
            // 将token和过期时间保存到TokenStorage中
            appTokenStorage.setToken(token, expirationTime);
        }
        return token;
    }
}
